from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:11434/v1",  # Ollama默认API地址
    api_key="test"  # 必填字段但会被忽略，随便填写即可
)

response = client.chat.completions.create(
    model="bsahane/Qwen2.5-VL:7b",  # 替换为已下载的模型名称
    messages=[
        # {"role": "system", "content": "你是一个有帮助的助手"},
        {
            "role": "user",
            "content": [
                {"type": "image", "image": {"url": "https://cdn.qwenlm.ai/4d55925e-3d35-4196-ac2d-05d6fff09d9b/866806b5-a8c9-4153-86c0-b3b1890a4577_0785fe90-2232-4697-a8dd-3b56d4e62711.png?key=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyZXNvdXJjZV91c2VyX2lkIjoiNGQ1NTkyNWUtM2QzNS00MTk2LWFjMmQtMDVkNmZmZjA5ZDliIiwicmVzb3VyY2VfaWQiOiI4NjY4MDZiNS1hOGM5LTQxNTMtODZjMC1iM2IxODkwYTQ1NzciLCJyZXNvdXJjZV9jaGF0X2lkIjpudWxsfQ.tbb5PhlMDNC-v1Fg6yNERCd4bdVTS57zWglEWHWKyFM"}},
                {"type": "text", "text": "请用中文回答我的问题：这个图片是什么？"}
            ]
        }
    ],
    temperature=0.7,
    max_tokens=300
)

print(response.choices[0].message.content)
